package GMDPRE

import "fmt"

func down8bytes(n uint64) []uint8 {
	res := make([]uint8, 8)
	res[0] = uint8((n >> 56) & 0xff)
	res[1] = uint8((n >> 48) & 0xff)
	res[2] = uint8((n >> 40) & 0xff)
	res[3] = uint8((n >> 32) & 0xff)
	res[4] = uint8((n >> 24) & 0xff)
	res[5] = uint8((n >> 16) & 0xff)
	res[6] = uint8((n >> 8) & 0xff)
	res[7] = uint8(n & 0xff)
	return res
}

func StringToBytes(str string) []uint8 {
	var res []uint8
	for i := 0; i < len(str); i++ {
		res = append(res, str[i])
	}
	return res
}

func PrintBytesHex(b []uint8, inLen int) {
	var i int
	for i = 0; i < inLen; i++ {
		fmt.Printf("%02x", b[i])

		if (i+1)&0b11 == 0 {
			fmt.Print(" ")
		}
		if (i+1)&0x1f == 0 {
			fmt.Println()
		}
	}
	if i&0x1f != 0 {
		fmt.Println()
	}
}
